package siteconfig

import (
	"github.com/gogf/gf/os/gcache"
	siteconfigModel "myblog/app/model/system/siteconfig"
)

//修改数据
func Edit(req *siteconfigModel.EditReq) error {
	return siteconfigModel.Edit(req)

}

//获取数据
func SelectList() ([]siteconfigModel.Entity, error) {
	return siteconfigModel.SelectList()
}

//获取数据
func GetValueByName(key string) (string, error) {
	resultStr := ""
	result, err := gcache.Get(key)
	if err != nil {
		return "", err
	}
	if result == nil {
		configRecord, err := siteconfigModel.GetValueByName(key)
		if err != nil {
			return "", err
		}

		resultStr = configRecord
		gcache.Set(key, resultStr, 0)
	} else {
		resultStr = result.(string)
	}

	return resultStr, nil
}
